// ==UserScript==
// @name Sweet Timeline - Modified
// @modified Joseph Selby
// @namespace http://userscripts.org/scripts/show/129894
// @copyright (C) David Cabrera 2012.
// @author David Cabrera http://www.facebook.com/edacmo
// @version 1.36.1
// @description Modify the new Facebook Timeline to show all post in an unique block.
// @updateURL https://userscripts42.googlecode.com/svn/sweet_timeline/sweettimeline_FF.meta.js
// @include http://www.facebook.com/*
// @include https://www.facebook.com/*
// ==/UserScript==

/* CHANGES:
 * # Fixed images moved to left, maximum width added.
 * 
 * # Fixed all embed videos to fit the maximum width. 
 * # Fixed all external shared videos to center. 
 * 
 * # Added changes to support navigation to the past.
 * # Modified the filter button to the left of the screen.
 * # Fixed to center the navigation buttons to the past.
 * # Fixed to center all Cover, Profile and normal Photos
 * # Fixed to center all Videos.
 * # Fixed all preview of Text, Notes, Links, etc... 
 */


(function(timeline) {
    if (!document.getElementById('globalContainer') || document.getElementById('sweetGadget')) {
        return;
    }
    var AppInfo = {
        name: 'Sweet Timeline',
        version: '1.36.2',
        url: 'http://userscripts.org/scripts/show/129894'
    }
    var CssText = atob(
    'Ym9keSB7DQpiYWNrZ3JvdW5kOiB3aGl0ZSAhaW1wb3J0YW50Ow0KfQ0KI3JpZ2h0Q29sQ29udGVu' +
'dCAucGFnZXNUaW1lbGluZUJ1dHRvblBhZ2VsZXQgew0KYmFja2dyb3VuZC1jb2xvcjogd2hpdGUg' +
'IWltcG9ydGFudDsNCn0NCiNzd2VldEdhZGdldCB7DQp3aWR0aDogMjAwcHg7DQpwb3NpdGlvbjog' +
'YWJzb2x1dGU7DQpoZWlnaHQ6IGF1dG87DQptYXJnaW4tdG9wOiAxNXB4Ow0KfQ0KI3N3ZWV0R2Fk' +
'Z2V0ID4gZGl2IHsNCmJvcmRlcjogMXB4IHNvbGlkICNDNENERTA7DQptYXJnaW46IDBweCAwcHgg' +
'MTBweCAwcHg7DQpwYWRkaW5nOiA0cHg7DQp9DQojc3dlZXRHYWRnZXQgLm9nUmVjZW50VGl0bGUg' +
'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W50IC5mYlRpbWVsaW5lT25lQ29sdW1uIC5leHRlcm5hbFNoYXJlVGV4dCB7DQp3aWR0' +
'aDogYXV0byAhaW1wb3J0YW50Ow0KfQ0KI3RpbWVsaW5lX3RhYl9jb250ZW50IC5mYlRpbWVsaW5l' +
'T25lQ29sdW1uIC5oYXNJbWFnZSAuZXh0ZXJuYWxTaGFyZVRleHQgew0Kd2lkdGg6IDQ4MHB4ICFp' +
'bXBvcnRhbnQ7DQp9DQojdGltZWxpbmVfdGFiX2NvbnRlbnQgLmxpa2VVbml0IC5saWtlVW5pdFRv' +
'b2x0aXAgew0KaGVpZ2h0OiAxMzBweCAhaW1wb3J0YW50Ow0KfQ0KI3RpbWVsaW5lX3RhYl9jb250' +
'ZW50IC5mYlRpbWVsaW5lT25lQ29sdW1uIC5saWZlRXZlbnRBZGRQaG90byB7DQp3aWR0aDogYXV0' +
'byAhaW1wb3J0YW50Ow0KfQ0KI3RpbWVsaW5lX3RhYl9jb250ZW50IC5mYlRpbWVsaW5lQ29tcG9z' +
'ZXJDYXBzdWxlIHsNCnotaW5kZXg6IDMgIWltcG9ydGFudDsNCn0=');
    
    /*var SweetGadget = null, StyleDoc = document.createElement('style');
    StyleDoc.setAttribute('type', 'text/css');
    StyleDoc.appendChild(document.createTextNode(CssText));
    document.head.appendChild(StyleDoc);*/

	var SweetGadget = null, StyleDoc = document.createElement('link');
    StyleDoc.setAttribute('type', 'text/css');
	StyleDoc.setAttribute('rel', 'stylesheet');
    StyleDoc.setAttribute('href', 'https://userscripts42.googlecode.com/svn/sweet_timeline/fb_css.css');
    document.head.appendChild(StyleDoc);
	
    timeline=CssText=StyleDoc=null;
    
    if (addGadget() === true) {
        dockPages(document);
    }
    
    document.addEventListener('DOMSubtreeModified', function(e) {
        if (!document.getElementById('sweetGadget')) {
            if (addGadget() !== true) {
                return;
            }
        }
        if (e.target) {
            if (e.target.id=='pagelet_timeline_recent'
            || /fbTimelineCapsule/.test(e.target.className)) {
                dockPages(e.target);
            }
        }
    }, false);
    
    function addGadget() {
        var ContentDoc = document.getElementById('timeline_tab_content');
        var div = document.createElement('div');
        if (!ContentDoc || !document.querySelector('ol.fbTimelineCapsule')) {
            return false;
        }
        SweetGadget = document.createElement('div');
        SweetGadget.setAttribute('id', 'sweetGadget');
        ContentDoc.insertBefore(SweetGadget, ContentDoc.firstChild);
        div.setAttribute('id', 'sweet_version_info');
        div.setAttribute('style', 'text-align: center;');
        div.innerHTML = '<a href="'+AppInfo.url+'" target="_blank">'+AppInfo.name +' v'+ AppInfo.version +'</a><br/>Modified by: <a href="https://www.facebook.com/profile.php?id=100000457520388&ref=tn_tnmn" target="_blank">Joseph Selby</a>';
        SweetGadget.appendChild(div);
        return true;
    }
    function dockPages(target) {
        if (!SweetGadget) {
            return;
        }
        var element;
        if ((element = target.querySelector('.fbTimelineFilters'))) {
            document.getElementById('sweet_version_info').appendChild(element);
        }
        if ((element = target.querySelector('.pageFriendSummaryContainer'))) {
            element.parentNode.style.display = 'none';
            SweetGadget.appendChild(element);
        }            
        if ((element = target.querySelector('#pagelet_page_most_recent_unit_wrapper'))) {
            element.style.display = 'none';
            element = element.querySelector('.timelineUnitContainer');
            if (element) {
                SweetGadget.appendChild(element);
            }
        }            
        if ((element = target.querySelector('#liked_pages_timeline_unit_list'))) {
            element.parentNode.parentNode.parentNode.style.display = 'none';
            SweetGadget.appendChild(element.parentNode.parentNode);
        }            
        if ((element = target.querySelector('#pagelet_timeline_friends_unit'))) {
            element.parentNode.parentNode.style.display = 'none';
            SweetGadget.appendChild(element);
        }
        if ((element = target.querySelector('.recentActivityUnit'))) {
            element.parentNode.style.display = 'none';
            SweetGadget.appendChild(element);
        }
        if ((element = target.querySelector('.recentAppsHeader'))) {
            element = element.parentNode.parentNode;
            element.parentNode.style.display = 'none';
            SweetGadget.appendChild(element);
        }
        
        if ((element = target.querySelector('.videoUnit a.videoThumb[href*=max_width]'))) {
            var width = /max_width=(\d+)/i.exec(element.href);
            if (width && parseInt(width[1]) > 614) {
                element.href = element.href.replace(/max_width=(\d+)/i, 'max_width=614');
            }
        }
    }
})();